package com.bwie.spu.controller;

import com.bwie.common.core.web.domain.AjaxResult;
import com.bwie.spu.domain.vo.ProductDetailVo;
import com.bwie.spu.service.ProductDetailService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.concurrent.ExecutionException;

@RestController
@RequestMapping("detail")
@CrossOrigin
public class ProductDetailController {
    /**
     * 注入
     */
    @Autowired
    private ProductDetailService service;

    /**
     * 根据skuId,获得商品详情
     * @param skuId
     * @return
     */
    @GetMapping("getProductDetail/{skuId}")
    public AjaxResult getProductDetail(@PathVariable Integer skuId) throws ExecutionException, InterruptedException {
        //调用方法
        ProductDetailVo productDetailVo = service.getProductDetail(skuId);
        //返回
        return AjaxResult.success(productDetailVo);
    }
}
